<?php
function showTravelstyle($country_id=''){
	global $lang, $mod, $mod_travelstyle, $country_array;	
	$xtpl=new XTemplate("themes/".theme."/html/travelstyle.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('lbl', TravelStyle);
	
	$xtpl->assign('mod', $mod);
	$xtpl->assign('mod_travelstyle', $mod_travelstyle);
	
	//
	$cond = " AND t.lang = '".$lang."'";
	if($country_id){
		$xtpl->assign('country_code', $country_array[2].'/');
		
		$cond .= " AND ct.country_id = '".$country_id."'";
		$sql_travelstyle = "SELECT t.travelstyle_id, t.travelstyle_name FROM ".pre_table."travelstyle t, ".pre_table."country_travelstyle ct
					WHERE t.travelstyle_id=ct.travelstyle_id AND t.travelstyle_isactive=1 ".$cond." 
					ORDER BY t.travelstyle_position";
	}else{
		$sql_travelstyle = "SELECT t.travelstyle_id, t.travelstyle_name FROM ".pre_table."travelstyle t
					WHERE t.travelstyle_isactive=1 ".$cond." 
					ORDER BY t.travelstyle_position";
	}
	
	$rs_travelstyle = execSQL($sql_travelstyle);
	if(mysql_num_rows($rs_travelstyle)>0){
		while($row_travelstyle = mysql_fetch_array($rs_travelstyle)){
			$row_travelstyle['TravelstyleName'] = codau2kodau($row_travelstyle['travelstyle_name']);
			
			$xtpl->assign("list",$row_travelstyle);	
			$xtpl->parse("BLOCK.LIST");
		}				
	}
	
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;	
}
///
function showTravelstyleDetail($country_id='', $travelstyle_id){
	global $lang, $mod_tour, $travelstyle_brief;
	$xtpl=new XTemplate("themes/".theme."/html/travelstyle_tour.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('mod_tour', $mod_tour);
	
	$xtpl->assign('lbl', Tour);
	$xtpl->assign('lbl_more', More);
	
	
	$path = 'media/tour/';
	$width = 180;

	$xtpl->assign('travelstyle_brief', $travelstyle_brief);
	
	//
	$cond = " AND t.lang = '".$lang."'";
	if($country_id) $cond .= " AND t.country_id = '".$country_id."'";
	
	// page
	$page=intval($_GET['page']);
	$limit=10;$pagegroup_size=5;
	if (!$page||$page==0){$page=1;}
	$offset=($page-1)*$limit;
	$xtpl->assign("page",$page);
	
	$sql_count = "SELECT t.tour_id FROM ".pre_table."tour t INNER JOIN
				 ".pre_table."country c ON c.country_id=t.country_id
				INNER JOIN ".pre_table."tour_travelstyle tt ON t.tour_id=tt.tour_id 
				WHERE tt.travelstyle_id='".$travelstyle_id."' AND t.tour_isactive=1 ".$cond."";
	$rs_count = execSQL($sql_count);
	$numrec=mysql_num_rows($rs_count);
	
	$sql = "SELECT t.tour_id, t.tour_name, t.tour_brief, t.tour_image, c.country_code FROM ".pre_table."tour t INNER JOIN
				 ".pre_table."country c ON c.country_id=t.country_id
				INNER JOIN ".pre_table."tour_travelstyle tt ON t.tour_id=tt.tour_id 
				WHERE tt.travelstyle_id='".$travelstyle_id."' AND t.tour_isactive=1 ".$cond." 
				ORDER BY t.tour_position LIMIT $offset, $limit";
	$rs=execSQL($sql);
	if(mysql_num_rows($rs)>0){
		while($row=mysql_fetch_array($rs)){
			$row['TourName'] = codau2kodau($row['tour_name']);
			
			if($row['tour_image']){
				if(file_exists(const_Web_Path.$path.$row['tour_image'])){
					$row['tour_image'] = '<img src="'.const_Web_Url.$path.'thumb_'.$width.'_'.$row['tour_image'].'" width="'.$width.'" title="'.$row['tour_name'].'" alt="'.$row['tour_name'].'" border="0" vspace="5" hspace="5" class="img" />';	
				}else{
					$row['tour_image'] = '';	
				}
			}else{
				$row['tour_image'] = '';
			}
			
			$xtpl->assign("list",$row);
			$xtpl->parse("BLOCK.LIST");
		}
		$pages=pagenavigator($page,$numrec,$limit,$pagegroup_size,"page_no",const_Web_Url.'index.php'.$_SERVER['PATH_INFO']."".$page_str."");
		$xtpl->assign("pages",$pages);
		//$xtpl->assign("numrec", "".$numrec."");
	}
	
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;	
}
///
function showLogo(){
	global $lang;	
	$xtpl=new XTemplate("themes/".theme."/html/logo.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('lbl', Logo);
	
	$path = 'media/logo/';
	//
	$cond = " AND l.lang = '".$lang."' AND tab=''";

	$sql = "SELECT l.logo_id, l.logo_name, l.logo_link, l.logo_image
				FROM ".pre_table."logo l
				WHERE logo_isactive=1 ".$cond." ORDER BY logo_position";
	$rs=execSQL($sql);
	if(mysql_num_rows($rs)>0){
		while($row=mysql_fetch_array($rs)){
			
			if($row['logo_image']){
				if(file_exists(const_Web_Path.$path.$row['logo_image'])){
					$row['logo_image'] = '<img src="'.const_Web_Url.$path.$row['logo_image'].'" width="200" title="'.$row['logo_name'].'" alt="'.$row['logo_name'].'" border="0" vspace="5" hspace="5" />';	
				}else{
					$row['logo_image'] = '';	
				}
			}else{
				$row['logo_image'] = '';
			}
			
			$xtpl->assign("list",$row);
			$xtpl->parse("BLOCK.LIST");
		}
	}
	
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;	
}
///
function showSlideshow($country_id='', $tab=''){
	global $lang;	
	$xtpl=new XTemplate("themes/".theme."/html/slideshow.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('lbl', Slideshow);
	
	$path = 'media/slideshow/';
	//
	$cond = " AND l.lang = '".$lang."' AND tab<>''";
	if($country_id) $cond .= " AND l.country_id = '".$country_id."'";
	if($tab) $cond .= " AND l.tab = '".$tab."'";

	$sql = "SELECT l.logo_id, l.logo_name, l.logo_link, l.logo_image
				FROM ".pre_table."logo l
				WHERE logo_isactive=1 ".$cond." ORDER BY logo_position";
	$rs=execSQL($sql);
	if(mysql_num_rows($rs)>0){
		$i=0;
		while($row=mysql_fetch_array($rs)){
			$i++;
			if($i==1) $row['class'] = 'show';
			
			if($row['logo_link']){
				$row['logo_link'] = $row['logo_link'];
			}else{
				$row['logo_link'] = '';
			}
			
			if($row['logo_image']){
				if(file_exists(const_Web_Path.$path.$row['logo_image'])){
					$row['logo_image'] = '<a href="'.$row['logo_link'].'" class="'.$row['class'].'"><img src="'.const_Web_Url.$path.$row['logo_image'].'" width="570" height="223" title="'.$row['logo_name'].'" alt="'.$row['logo_name'].'" rel="<h3>'.$row['logo_name'].'</h3>" border="0" /></a>';	
				}else{
					$row['logo_image'] = '';	
				}
			}else{
				$row['logo_image'] = '';
			}
			
			$xtpl->assign("list",$row);
			$xtpl->parse("BLOCK.LIST");
		}
	}else{
		$row['logo_image'] = '<a href="" class="active"><img src="'.const_Web_Url.'themes/'.theme.'/images/slideshow.jpg" width="570" height="223" rel="" border="0" /></a>';
		
		$xtpl->assign("list",$row);
		$xtpl->parse("BLOCK.LIST");

	}
	
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;	
}
///
function showOther($other_id=''){
	global $lang;
	$xtpl=new XTemplate("themes/".theme."/html/other.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$path = 'media/other/';
	$xtpl->assign('lbl', News);
		
	if($lang=='v'){
		$mod = 'tin-tuc';
	}else{
		$mod = 'news';
	}
	$xtpl->assign('mod', $mod);
	//	
	$cond = " AND lang='".lang."'";
	$sql = "SELECT other_id, other_name, other_content
				FROM ".pre_table."other 
				WHERE other_isactive=1 AND other_id='".$other_id."' ".$cond." 
				ORDER BY other_position LIMIT 1";
	$rs=recordset($sql);

	$row["other_id"] = $rs["other_id"];
	$row["other_name"] = $rs["other_name"];
	$row['other_content'] = $rs['other_content'];
	$row['OtherName'] = codau2kodau($rs["other_name"]);
	
	$xtpl->assign("detail",$row);

						
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;	
}
///
function showOtherService(){
	global $lang;
	$xtpl=new XTemplate("themes/".theme."/html/otherservice.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('lbl', OtherService);
	$xtpl->assign('lbl_top', Top);

	//
	$not_in = "3,5";
	$cond = " AND o.lang = '".$lang."' AND other_id NOT IN (".$not_in.")";

	$sql = "SELECT o.other_id, o.other_name, o.other_content
				FROM ".pre_table."other o
				WHERE other_isactive=1 ".$cond." ORDER BY other_position";
	$rs=execSQL($sql);
	$i=1;
	while($row=mysql_fetch_array($rs)){
		$row['num'] = $i++;
		
		$row['other_name2'] = strtoupper($row["other_name"]);
		
		$xtpl->assign("list",$row);
		$xtpl->parse("BLOCK.LIST");
		$xtpl->parse("BLOCK.LIST2");
	}
						
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;
}
///
function showReview($country_id=''){
	global $lang, $mod_review;	
	$xtpl=new XTemplate("themes/".theme."/html/review.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('lbl', Review);
	$xtpl->assign('lbl_more', More);
	
	$path = 'media/review/';

	$xtpl->assign('mod_review', $mod_review);
	
	//
	$cond = " AND r.lang = '".$lang."'";
	if($country_id) $cond .= " AND r.country_id = '".$country_id."'";
	
	$sql = "SELECT r.review_id, r.review_name, r.review_brief, r.review_image, c.country_code 
				FROM ".pre_table."review r, ".pre_table."country c 
				WHERE c.country_id=r.country_id AND review_isactive=1 ".$cond." ORDER BY review_position";
	$rs=execSQL($sql);
	if(mysql_num_rows($rs)>0){
		while($row=mysql_fetch_array($rs)){
			$row['ReviewName'] = codau2kodau($row['review_name']);
			
			if($row['review_image']){
				if(file_exists(const_Web_Path.$path.$row['review_image'])){
					$row['review_image'] = '<img src="'.const_Web_Url.$path.$row['review_image'].'" width="50" title="'.$row['review_name'].'" alt="'.$row['review_name'].'" border="0" vspace="5" hspace="5" class="img" />';	
				}else{
					$row['review_image'] = '';	
				}
			}else{
				$row['review_image'] = '';
			}
			
			$xtpl->assign("list",$row);
			$xtpl->parse("BLOCK.LIST");
		}
	}
	
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;	
}
///
function showReviewDetail($country_id){
	global $lang, $mod_review;
	$xtpl=new XTemplate("themes/".theme."/html/review_detail.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('lbl', Review);
	$xtpl->assign('lbl_top', Top);
	
	$xtpl->assign('mod_review', $mod_review);
	$path = 'media/review/';
	//
	$cond = " AND r.lang = '".$lang."'";
	if($country_id) $cond .= " AND r.country_id = '".$country_id."'";

	$sql = "SELECT r.review_id, r.review_name, r.review_content, r.review_image, c.country_code 
				FROM ".pre_table."review r, ".pre_table."country c 
				WHERE c.country_id=r.country_id AND review_isactive=1 ".$cond." ORDER BY review_position";
	$rs=execSQL($sql);
	$i=1;
	while($row=mysql_fetch_array($rs)){
		if($row['review_image']){
			if(file_exists(const_Web_Path.$path.$row['review_image'])){
				$row['review_image'] = '<img src="'.const_Web_Url.$path.$row['review_image'].'" width="50" title="'.$row['review_name'].'" alt="'.$row['review_name'].'" border="0" vspace="5" hspace="5" class="img" />';	
			}else{
				$row['review_image'] = '';	
			}
		}else{
			$row['review_image'] = '';
		}
		
		$xtpl->assign("list",$row);
		$xtpl->parse("BLOCK.LIST");
	}
						
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;	
}
///
function showFaq(){
	global $lang, $mod;	
	$xtpl=new XTemplate("themes/".theme."/html/faq.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('lbl', Faq);
	
	$xtpl->assign('mod', $mod);
	
	//
	$cond = " AND lang = '".$lang."'";

	$sql_country = "SELECT country_id, country_name, country_code FROM ".pre_table."country
					WHERE country_isactive=1 ".$cond." 
					ORDER BY country_position";
	$rs_country = execSQL($sql_country);
	if(mysql_num_rows($rs_country)>0){
		while($row_country = mysql_fetch_array($rs_country)){
			
			$xtpl->assign("list",$row_country);	
			$xtpl->parse("BLOCK.LIST");
		}				
	}
	
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;	
}
///
function showFaqDetail($country_id){
	global $lang;
	$xtpl=new XTemplate("themes/".theme."/html/faq_detail.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('lbl', Faq);
	$xtpl->assign('lbl_top', Top);

	//
	$cond = " AND f.lang = '".$lang."'";
	if($country_id) $cond .= " AND f.country_id = '".$country_id."'";

	$sql = "SELECT f.faq_id, f.faq_name, f.faq_content, c.country_code 
				FROM ".pre_table."faq f, ".pre_table."country c 
				WHERE c.country_id=f.country_id AND faq_isactive=1 ".$cond." ORDER BY faq_position";
	$rs=execSQL($sql);
	$i=1;
	while($row=mysql_fetch_array($rs)){
		$row['num'] = $i++;
		$xtpl->assign("list",$row);
		$xtpl->parse("BLOCK.LIST");
		$xtpl->parse("BLOCK.LIST2");
	}
						
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;	
}
///
function showNews($country_id=''){
	global $lang, $mod_news;
	$xtpl=new XTemplate("themes/".theme."/html/news.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('lbl', News);
	$path = 'media/news/';
	$width = 50;

	$xtpl->assign('mod_news', $mod_news);
	
	//
	$cond = " AND lang = '".$lang."'";
	if($country_id) $cond .= " AND country_id = '".$country_id."'";
	
	$sql = "SELECT news_id, news_name, news_brief, news_image FROM ".pre_table."news 
				WHERE news_isactive=1 ".$cond." ORDER BY news_position";
	$rs=execSQL($sql);
	if(mysql_num_rows($rs)>0){
		while($row=mysql_fetch_array($rs)){
			$row['NewsName'] = codau2kodau($row['news_name']);
			
			if($row['news_image']){
				if(file_exists(const_Web_Path.$path.$row['news_image'])){
					$row['news_image'] = '<img src="'.const_Web_Url.$path.'thumb_'.$width.'_'.$row['news_image'].'" width="'.$width.'" title="'.$row['news_name'].'" alt="'.$row['news_name'].'" border="0" vspace="5" hspace="5" class="img" />';	
				}else{
					$row['news_image'] = '';	
				}
			}else{
				$row['news_image'] = '';
			}
			
			$xtpl->assign("list",$row);
			$xtpl->parse("BLOCK.LIST");
		}
	}
	
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;	
}
///
function showNewsDetail($news_id){
	global $lang, $mod_news;
	$xtpl=new XTemplate("themes/".theme."/html/news_detail.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$path = 'media/news/';
	$xtpl->assign('lbl', News);
	$xtpl->assign('lbl_othernews', OtherNews);
	
	$xtpl->assign('mod_news', $mod_news);
	//	
	$cond = " AND lang='".lang."'";
	$sql = "SELECT news_id, news_name, news_image, news_brief, news_content
				FROM ".pre_table."news 
				WHERE news_isactive=1 AND news_id='".$news_id."' ".$cond." 
				ORDER BY news_position LIMIT 1";
	$rs=recordset($sql);

	$row["news_id"] = $rs["news_id"];
	$row["news_name"] = $rs["news_name"];
	$row['news_brief'] = nl2br($rs['news_brief']);
	$row['news_content'] = $rs['news_content'];
	$row['NewsName'] = codau2kodau($rs["news_name"]);
	
	if($rs['news_image']){
		if(file_exists(const_Web_Path.$path.$rs['news_image'])){
			$row['news_image']='<img src="'.const_Web_Url.$path.$rs['news_image'].'" width="150" title="'.$rs['news_name'].'" alt="'.$rs['news_name'].'" border="0" vspace="5" hspace="5" class="img" />';	
		}else{
			$row['news_image']='';	
		}
	}else{
		$row['news_image']='';
	}
	
	$xtpl->assign("detail",$row);
	
	// ++ other news
	$sql_other = "SELECT news_id, news_name FROM ".pre_table."news
					WHERE news_isactive=1 AND news_id<>'".$news_id."' ".$cond." 
					ORDER BY news_id DESC LIMIT 0, 13";
	$rs_other = execSQL($sql_other);
	while($row_other = mysql_fetch_array($rs_other)){
		
		$row_other['NewsName'] = codau2kodau($row_other["news_name"]);
		
		$xtpl->assign("list",$row_other);	
		$xtpl->parse("BLOCK.LIST");
	}				
	// -- other news
						
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;	
}
///
function showTourHome($country_id='', $ishome='', $isdestination=''){
	global $lang, $mod, $mod_tour, $country_array;
	$xtpl=new XTemplate("themes/".theme."/html/tour_home.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('mod_tour', $mod_tour);
	
	if($isdestination){
		$xtpl->assign('lbl', Tour.' '.In.' '.$country_array[1]);
		$xtpl->assign('all', '<a href="'.const_Web_Url.'index.php/'.$mod_tour.'/'.$country_array[2].'" class="path">'.See.' '.$country_array[1].' '.Tour.'<a>');
	}else{
		$xtpl->assign('lbl', Tour);
	}	
		
	$xtpl->assign('lbl_duration', Duration);
	$xtpl->assign('lbl_travelstyle', TravelStyle);	
	$xtpl->assign('lbl_price', Price);

	$xtpl->assign('lbl_more', More);
	
	
	$path = 'media/tour/';
	$width = 230;
	$height = 113;
	
	//
	$cond = " AND t.lang = '".$lang."'";
	if($country_id) $cond .= " AND t.country_id = '".$country_id."'";
	if($ishome) $cond .= " AND t.tour_ishome = 1";
	if($isdestination) $cond .= " AND t.tour_isdestination = 1";
	
	$sql = "SELECT t.tour_id, t.tour_name, t.tour_duration, t.tour_price, t.tour_image, c.country_code FROM ".pre_table."tour t, ".pre_table."country c 
				WHERE c.country_id=t.country_id AND tour_isactive=1 ".$cond." ORDER BY tour_position LIMIT 0, 10";
	$rs=execSQL($sql);
	if(mysql_num_rows($rs)>0){
		$i=0;
		while($row=mysql_fetch_array($rs)){
			$i++;
			if($i%2==0){
				$row['clear'] = '<br class="clear">';
			}
			
			$row['TourName'] = codau2kodau($row['tour_name']);
			
			if($row['tour_image']){
				if(file_exists(const_Web_Path.$path.$row['tour_image'])){
					$row['tour_image'] = '<img src="'.const_Web_Url.$path.$row['tour_image'].'" width="'.$width.'" height="'.$height.'" title="'.$row['tour_name'].'" alt="'.$row['tour_name'].'" border="0" vspace="5" hspace="5" class="img" />';	
				}else{
					$row['tour_image'] = '';	
				}
			}else{
				$row['tour_image'] = '';
			}
			
			// ++ travel style
			$sql_travelstyle = "SELECT ts.travelstyle_name FROM ".pre_table."travelstyle ts, ".pre_table."tour_travelstyle t_ts
								WHERE ts.travelstyle_id=t_ts.travelstyle_id AND t_ts.tour_id='".$row['tour_id']."'";
			$rs_travelstyle = execSQL($sql_travelstyle);
			if(mysql_num_rows($rs_travelstyle)>0){
				while($row_travelstyle = mysql_fetch_array($rs_travelstyle)){
					$row['travelstyle_name'] .= $row_travelstyle['travelstyle_name'].', ';
				}
			}
			$row['travelstyle_name'] = substr($row['travelstyle_name'],0, -2);
			// -- travel style
			
			$xtpl->assign("list",$row);
			$xtpl->parse("BLOCK.LIST");
		}
	}
	
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;	
}
///
function showTour($country_id=''){
	global $lang, $mod_tour;
	$xtpl=new XTemplate("themes/".theme."/html/tour.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('mod_tour', $mod_tour);
	
	$xtpl->assign('lbl', Tour);
	$xtpl->assign('lbl_more', More);
	
	
	$path = 'media/tour/';
	$width = 180;

	
	
	//
	$cond = " AND t.lang = '".$lang."'";
	if($country_id) $cond .= " AND t.country_id = '".$country_id."'";
	
	// page
	$page=intval($_GET['page']);
	$limit=10;$pagegroup_size=5;
	if (!$page||$page==0){$page=1;}
	$offset=($page-1)*$limit;
	$xtpl->assign("page",$page);
	
	$sql_count = "SELECT t.tour_id FROM ".pre_table."tour t, ".pre_table."country c
				WHERE c.country_id=t.country_id AND tour_isactive=1 ".$cond." ORDER BY tour_position";
	$rs_count = execSQL($sql_count);
	$numrec=mysql_num_rows($rs_count);
	
	$sql = "SELECT t.tour_id, t.tour_name, t.tour_brief, t.tour_image, c.country_code FROM ".pre_table."tour t, ".pre_table."country c 
				WHERE c.country_id=t.country_id AND tour_isactive=1 ".$cond." ORDER BY tour_position LIMIT $offset, $limit";
	$rs=execSQL($sql);
	if(mysql_num_rows($rs)>0){
		while($row=mysql_fetch_array($rs)){
			$row['TourName'] = codau2kodau($row['tour_name']);
			
			if($row['tour_image']){
				if(file_exists(const_Web_Path.$path.$row['tour_image'])){
					$row['tour_image'] = '<img src="'.const_Web_Url.$path.'thumb_'.$width.'_'.$row['tour_image'].'" width="'.$width.'" title="'.$row['tour_name'].'" alt="'.$row['tour_name'].'" border="0" vspace="5" hspace="5" class="img" />';	
				}else{
					$row['tour_image'] = '';	
				}
			}else{
				$row['tour_image'] = '';
			}
			
			$xtpl->assign("list",$row);
			$xtpl->parse("BLOCK.LIST");
		}
		$pages=pagenavigator($page,$numrec,$limit,$pagegroup_size,"page_no",const_Web_Url.'index.php'.$_SERVER['PATH_INFO']."".$page_str."");
		$xtpl->assign("pages",$pages);
		//$xtpl->assign("numrec", "".$numrec."");
	}
	
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;	
}
///
function showTourDetail($country_id, $tour_id){
	global $lang, $mod_tour, $mod_booktour;
	$xtpl=new XTemplate("themes/".theme."/html/tour_detail.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('theme_tab', theme_tab);
	$xtpl->assign('mod_tour', $mod_tour);
	
	$path = 'media/tour/';
	$xtpl->assign('lbl', Tour);
	$xtpl->assign('lbl_overview', Overview);
	$xtpl->assign('lbl_itinerary', Itinerary);
	$xtpl->assign('lbl_rates', Rates);
	$xtpl->assign('lbl_gallery', Gallery);
	$xtpl->assign('lbl_extendtour', ExtendTour);
	$xtpl->assign('lbl_similartour', SimilarTour);
	$xtpl->assign('lbl_duration', Duration);
	$xtpl->assign('lbl_travelstyle', TravelStyle);	
	$xtpl->assign('lbl_price', Price);
	$xtpl->assign('lbl_more', More);
	$xtpl->assign('lbl_booktour', Book);
	
	$xtpl->assign('mod_booktour', $mod_booktour);
	
	//	
	$cond = " AND t.lang='".lang."'";
	$sql = "SELECT t.tour_id, t.tour_name, t.tour_duration, t.tour_image, t.tour_brief, t.tour_overview, t.tour_itinerary, t.tour_rates, t.tour_extend, t.tour_similar, tour_metadescription, tour_metakeyword
				FROM ".pre_table."tour t
				WHERE t.tour_isactive=1 AND t.tour_id='".$tour_id."' ".$cond." 
				ORDER BY t.tour_position LIMIT 1";
	$rs=recordset($sql);


	$row["tour_id"] = $rs["tour_id"];
	$row["tour_name"] = $rs["tour_name"];
	$row["tour_duration"] = $rs["tour_duration"];
	$row['tour_brief'] = nl2br($rs['tour_brief']);
	$row['tour_overview'] = $rs['tour_overview'];
	$row['tour_itinerary'] = $rs['tour_itinerary'];
	$row['tour_rates'] = $rs['tour_rates'];
	$row['TourName'] = codau2kodau($rs["tour_name"]);
	
	if($rs['tour_image']){
		if(file_exists(const_Web_Path.$path.$rs['tour_image'])){
			$row['tour_image']='<img src="'.const_Web_Url.$path.$rs['tour_image'].'" width="150" title="'.$rs['tour_name'].'" alt="'.$rs['tour_name'].'" border="0" vspace="5" hspace="5" class="img" />';	
		}else{
			$row['tour_image']='';	
		}
	}else{
		$row['tour_image']='';
	}
	
	$tour_extend = $rs['tour_extend'];
	$tour_similar = $rs['tour_similar'];
	
	$xtpl->assign("detail",$row);
	
	$width = 230;
	$height = 113;
	// ++ extend tour
	if($tour_extend){
		$sql_extend = "SELECT tour_id, tour_name, tour_image, tour_duration, tour_price, c.country_code 
						FROM ".pre_table."tour t, ".pre_table."country c
						WHERE c.country_id=t.country_id AND tour_isactive=1 AND tour_id IN (".$tour_extend.") ".$cond." 
						ORDER BY tour_id DESC LIMIT 0, 13";
		$rs_extend = execSQL($sql_extend);
		if(mysql_num_rows($rs_extend)>0){
			$i=0;
			while($row_extend = mysql_fetch_array($rs_extend)){
				$i++;
				if($i%2==0){
					$row_extend['clear'] = '<br class="clear">';
				}	
				$row_extend['TourName'] = codau2kodau($row_extend["tour_name"]);
				if($row_extend['tour_image']){
					if(file_exists(const_Web_Path.$path.$row_extend['tour_image'])){
						$row_extend['tour_image']='<img src="'.const_Web_Url.$path.$row_extend['tour_image'].'" width="'.$width.'" height="'.$height.'" title="'.$row_extend['tour_name'].'" alt="'.$row_extend['tour_name'].'" border="0" class="img" />';	
					}else{
						$row_extend['tour_image']='';	
					}
				}else{
					$row_extend['tour_image']='';
				}
				
				// ++ travel style
				$sql_travelstyle = "SELECT ts.travelstyle_name FROM ".pre_table."travelstyle ts, ".pre_table."tour_travelstyle t_ts
									WHERE ts.travelstyle_id=t_ts.travelstyle_id AND t_ts.tour_id='".$row_extend['tour_id']."'";
				$rs_travelstyle = execSQL($sql_travelstyle);
				if(mysql_num_rows($rs_travelstyle)>0){
					while($row_travelstyle = mysql_fetch_array($rs_travelstyle)){
						$row_extend['travelstyle_name'] .= $row_travelstyle['travelstyle_name'].', ';
					}
				}
				$row_extend['travelstyle_name'] = substr($row_extend['travelstyle_name'],0, -2);
				// -- travel style
				
				$xtpl->assign("extend",$row_extend);	
				$xtpl->parse("BLOCK.EXTEND.EXTEND_LIST");
			}				
			$xtpl->parse("BLOCK.EXTEND");
		}
	}
	// -- extend tour
	
	// ++ similar tour
	if($tour_similar){
		$sql_similar = "SELECT tour_id, tour_name, tour_image, tour_duration, tour_price, c.country_code FROM ".pre_table."tour t, ".pre_table."country c
						WHERE c.country_id=t.country_id AND tour_isactive=1 AND tour_id IN (".$tour_similar.") ".$cond." 
						ORDER BY tour_id DESC LIMIT 0, 13";
		$rs_similar = execSQL($sql_similar);
		if(mysql_num_rows($rs_similar)>0){
			$i=0;
			while($row_similar = mysql_fetch_array($rs_similar)){
				$i++;
				if($i%2==0){
					$row_similar['clear'] = '<br class="clear">';
				}	
				
				$row_similar['TourName'] = codau2kodau($row_similar["tour_name"]);
				if($row_similar['tour_image']){
					if(file_exists(const_Web_Path.$path.$row_similar['tour_image'])){
						$row_similar['tour_image']='<img src="'.const_Web_Url.$path.$row_similar['tour_image'].'" width="'.$width.'" height="'.$height.'" title="'.$row_similar['tour_name'].'" alt="'.$row_similar['tour_name'].'" border="0" class="img" />';	
					}else{
						$row_similar['tour_image']='';	
					}
				}else{
					$row_similar['tour_image']='';
				}
				
				// ++ travel style
				$sql_travelstyle = "SELECT ts.travelstyle_name FROM ".pre_table."travelstyle ts, ".pre_table."tour_travelstyle t_ts
									WHERE ts.travelstyle_id=t_ts.travelstyle_id AND t_ts.tour_id='".$row_similar['tour_id']."'";
				$rs_travelstyle = execSQL($sql_travelstyle);
				if(mysql_num_rows($rs_travelstyle)>0){
					while($row_travelstyle = mysql_fetch_array($rs_travelstyle)){
						$row_similar['travelstyle_name'] .= $row_travelstyle['travelstyle_name'].', ';
					}
				}
				$row_similar['travelstyle_name'] = substr($row_similar['travelstyle_name'],0, -2);
				// -- travel style
				
				$xtpl->assign("similar",$row_similar);	
				$xtpl->parse("BLOCK.SIMILAR.SIMILAR_LIST");
			}				
			$xtpl->parse("BLOCK.SIMILAR");
		}
	}
	// -- similar tour
	
	// ++ gallery
	$path_gallery = "media/gallery/";
	$width = 230;
	$sql_gallery = "SELECT gallery_id, gallery_name, gallery_image FROM ".pre_table."gallery
					WHERE gallery_isactive=1 AND tour_id='".$tour_id."'";
	$rs_gallery = execSQL($sql_gallery);
	while($row_gallery=mysql_fetch_array($rs_gallery)){
		$row_gallery['gallery_url']=const_Web_Url.$path_gallery.$row_gallery['gallery_image'];
		
		if($row_gallery['gallery_image']){
			if(file_exists(const_Web_Path.$path_gallery.$row_gallery['gallery_image'])){
				$row_gallery['gallery_image']='<img src="'.const_Web_Url.$path_gallery.'thumb_'.$width.'_'.$row_gallery['gallery_image'].'" width="'.$width.'" title="'.$row_gallery['gallery_name'].'" alt="'.$row_gallery['gallery_name'].'" border="0" />';	
			}else{
				$row_gallery['gallery_image']='';	
			}
		}else{
			$row_gallery['gallery_image']='';
		}
		
		$xtpl->assign("gallery",$row_gallery);	
		$xtpl->parse("BLOCK.GALLERY");
	}
	// -- gallery
	
	global $title, $metadescription, $metakeyword;
	$title = $rs['tour_name'];
	$metadescription = $rs['tour_metadescription'];
	$metakeyword = $rs['tour_metakeyword'];
	
		
						
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;	
}
///
function showBookTour($sent='', $tour_id){
	global $lang, $configuration_contact;
	$xtpl=new XTemplate("themes/".theme."/html/booktour.htm");	
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('theme_tab', theme_tab);
	$xtpl->assign('lbl', BookTour);
	
	$xtpl->assign('CustomerInfo', CustomerInfo);
	$xtpl->assign('Fullname', Fullname);
	$xtpl->assign('Phone', Phone);
	$xtpl->assign('Fax', Fax);
	$xtpl->assign('ContactDetail', ContactDetail);
	
	$xtpl->assign('TourInfo', TourInfo);
	$xtpl->assign('TourName', TourName);
	$xtpl->assign('StartDate', StartDate);
	$xtpl->assign('NumberGuest', NumberGuest);
	$xtpl->assign('NumberRoom', NumberRoom);
	$xtpl->assign('Additonal', Additonal);
	$xtpl->assign('SecurityCode', SecurityCode);	
	
	$xtpl->assign('Send', Send);
	$xtpl->assign('Back', Back);
	
	$xtpl->assign('Alert', Alert);
	$xtpl->assign('Required', Required);
	$xtpl->assign('LengthPhone', LengthPhone);
	$xtpl->assign('IsNumberic', IsNumberic);
	$xtpl->assign('Invalid', Invalid);
	
	$xtpl->assign('contact_info', $configuration_contact);
	//
	if($tour_id){
		$cond = " AND lang='".lang."'";
		$sql = "SELECT tour_name FROM ".pre_table."tour WHERE tour_id='".$tour_id."' ".$cond."";
		$rs = recordset($sql);
		$xtpl->assign('tour', $rs['tour_name']);
		$xtpl->assign('tour_id', $tour_id);
	}
	//
	//

	if($sent==1){
		$xtpl->parse("BLOCK.SENT");
	}
	
	$xtpl->parse("BLOCK");
	$out = $xtpl->text("BLOCK");
	
	return $out;
}
///
function showHotelHome($country_id='', $ishome='', $isdestination=''){
	global $lang, $mod, $mod_hotel, $country_array;
	$xtpl=new XTemplate("themes/".theme."/html/hotel_home.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('mod_hotel', $mod_hotel);
	
	if($isdestination){
		$xtpl->assign('lbl', Hotel.' '.In.' '.$country_array[1]);
		$xtpl->assign('all', '<a href="'.const_Web_Url.'index.php/'.$mod_hotel.'/'.$country_array[2].'" class="path">'.See.' '.$country_array[1].' '.Hotel.'<a>');
	}else{
		$xtpl->assign('lbl', Hotel);
	}	
	
	$xtpl->assign('lbl_more', More);
	
	
	$path = 'media/hotel/';
	$width = 230;
	$height = 113;
	
	//
	$cond = " AND h.lang = '".$lang."'";
	if($country_id) $cond .= " AND h.country_id = '".$country_id."'";
	if($ishome) $cond .= " AND h.hotel_ishome = 1";
	if($isdestination) $cond .= " AND h.hotel_isdestination = 1";
	
	$sql = "SELECT h.hotel_id, h.hotel_name, h.hotel_brief, h.hotel_image, c.country_code FROM ".pre_table."hotel h, ".pre_table."country c 
				WHERE c.country_id=h.country_id AND hotel_isactive=1 ".$cond." ORDER BY hotel_position LIMIT 0, 10";
	$rs=execSQL($sql);
	if(mysql_num_rows($rs)>0){
		$i=0;
		while($row=mysql_fetch_array($rs)){
			$i++;
			if($i%2==0){
				$row['clear'] = '<br class="clear">';
			}
		
			$row['HotelName'] = codau2kodau($row['hotel_name']);
			$row['hotel_brief'] = cutString($row['hotel_brief'], 200);
			
			if($row['hotel_image']){
				if(file_exists(const_Web_Path.$path.$row['hotel_image'])){
					$row['hotel_image'] = '<img src="'.const_Web_Url.$path.$row['hotel_image'].'" width="'.$width.'" height="'.$height.'" title="'.$row['hotel_name'].'" alt="'.$row['hotel_name'].'" border="0" vspace="5" hspace="5" class="img" />';	
				}else{
					$row['hotel_image'] = '';	
				}
			}else{
				$row['hotel_image'] = '';
			}

			$xtpl->assign("list",$row);
			$xtpl->parse("BLOCK.LIST");
		}
	}
	
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;	
}
///
function showHotel($country_id=''){
	global $lang, $mod_hotel;
	$xtpl=new XTemplate("themes/".theme."/html/hotel.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('mod_hotel', $mod_hotel);
	
	$xtpl->assign('lbl', Hotel);
	$xtpl->assign('lbl_more', More);
	
	
	$path = 'media/hotel/';
	$width = 180;

	
	//
	$cond = " AND h.lang = '".$lang."'";
	if($country_id) $cond .= " AND h.country_id = '".$country_id."'";
	
	// page
	$page=intval($_GET['page']);
	$limit=10;$pagegroup_size=5;
	if (!$page||$page==0){$page=1;}
	$offset=($page-1)*$limit;
	$xtpl->assign("page",$page);
	
	$sql_count = "SELECT h.hotel_id FROM ".pre_table."hotel h, ".pre_table."country c
				WHERE c.country_id=h.country_id AND hotel_isactive=1 ".$cond." ORDER BY hotel_position";
	$rs_count = execSQL($sql_count);
	$numrec=mysql_num_rows($rs_count);
	
	$sql = "SELECT h.hotel_id, h.hotel_name, h.hotel_brief, h.hotel_image, c.country_code 
				FROM ".pre_table."hotel h, ".pre_table."country c 
				WHERE c.country_id=h.country_id AND hotel_isactive=1 ".$cond." ORDER BY hotel_position LIMIT $offset, $limit";
	$rs=execSQL($sql);
	if(mysql_num_rows($rs)>0){
		while($row=mysql_fetch_array($rs)){
			$row['HotelName'] = codau2kodau($row['hotel_name']);
			
			if($row['hotel_image']){
				if(file_exists(const_Web_Path.$path.$row['hotel_image'])){
					$row['hotel_image'] = '<img src="'.const_Web_Url.$path.'thumb_'.$width.'_'.$row['hotel_image'].'" width="'.$width.'" title="'.$row['hotel_name'].'" alt="'.$row['hotel_name'].'" border="0" vspace="5" hspace="5" class="img" />';	
				}else{
					$row['hotel_image'] = '';	
				}
			}else{
				$row['hotel_image'] = '';
			}
			
			$xtpl->assign("list",$row);
			$xtpl->parse("BLOCK.LIST");
		}
		$pages=pagenavigator($page,$numrec,$limit,$pagegroup_size,"page_no",const_Web_Url.'index.php'.$_SERVER['PATH_INFO']."".$page_str."");
		$xtpl->assign("pages",$pages);
		//$xtpl->assign("numrec", "".$numrec."");
	}
	
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;	
}
///
function showHotelDetail($country_id, $hotel_id){
	global $lang, $mod_hotel, $mod_tour, $mod_bookhotel;
	$xtpl=new XTemplate("themes/".theme."/html/hotel_detail.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('theme_tab', theme_tab);
	$xtpl->assign('mod_hotel', $mod_hotel);
	
	$path = 'media/hotel/';
	$xtpl->assign('lbl', Tour);
	$xtpl->assign('lbl_overview', Overview);
	$xtpl->assign('lbl_indepth', Indepth);
	$xtpl->assign('lbl_location', Location);
	$xtpl->assign('lbl_traveladvice', TravelAdvice);
	$xtpl->assign('lbl_rates', Rates);
	$xtpl->assign('lbl_gallery', Gallery);
	$xtpl->assign('lbl_tour', Tour);
	$xtpl->assign('lbl_similarhotel', SimilarHotel);
	$xtpl->assign('lbl_duration', Duration);
	$xtpl->assign('lbl_travelstyle', TravelStyle);	
	$xtpl->assign('lbl_price', Price);
	$xtpl->assign('lbl_more', More);
	$xtpl->assign('lbl_bookhotel', Book);

	$xtpl->assign('mod_bookhotel', $mod_bookhotel);
	//	
	$cond = " AND h.lang='".lang."'";
	$sql = "SELECT h.hotel_id, h.hotel_name, h.hotel_image, h.hotel_brief, h.hotel_overview, h.hotel_indepth, h.hotel_location, h.	hotel_traveladvice, h.hotel_rates, h.hotel_tour, h.hotel_similar, h.hotel_metadescription, h.hotel_metakeyword, c.city_name
				FROM ".pre_table."hotel h, ".pre_table."city c
				WHERE h.city_id=c.city_id AND h.hotel_isactive=1 AND h.hotel_id='".$hotel_id."' ".$cond." 
				ORDER BY h.hotel_position LIMIT 1";
	$rs=recordset($sql);

	$row["hotel_id"] = $rs["hotel_id"];
	$row["hotel_name"] = $rs["hotel_name"];
	$row['hotel_brief'] = nl2br($rs['hotel_brief']);
	$row['hotel_overview'] = $rs['hotel_overview'];
	$row['hotel_indepth'] = $rs['hotel_indepth'];
	$row['hotel_location'] = $rs['hotel_location'];
	$row['hotel_traveladvice'] = $rs['hotel_traveladvice'];
	$row['hotel_rates'] = $rs['hotel_rates'];
	$row['HotelName'] = codau2kodau($rs["hotel_name"]);
	
	if($rs['hotel_image']){
		if(file_exists(const_Web_Path.$path.$rs['hotel_image'])){
			$row['hotel_image']='<img src="'.const_Web_Url.$path.$rs['hotel_image'].'" width="150" title="'.$rs['hotel_name'].'" alt="'.$rs['hotel_name'].'" border="0" vspace="5" hspace="5" class="img" />';	
		}else{
			$row['hotel_image']='';	
		}
	}else{
		$row['hotel_image']='';
	}
	
	$row['city_name'] = $rs['city_name'];
	
	$hotel_tour = $rs['hotel_tour'];
	$hotel_similar = $rs['hotel_similar'];
	
	$xtpl->assign("detail",$row);
	
	$width = 230;
	$height = 113;
	// ++ tour
	if($hotel_tour){
		$path_tour = 'media/tour/';
		$cond_tour = " AND t.lang='".lang."'";
		
		$sql_tour = "SELECT tour_id, tour_name, tour_image, tour_duration, tour_price, c.country_code 
						FROM ".pre_table."tour t, ".pre_table."country c
						WHERE c.country_id=t.country_id AND tour_isactive=1 AND tour_id IN (".$hotel_tour.") ".$cond_tour." 
						ORDER BY tour_id DESC LIMIT 0, 13";
		$rs_tour = execSQL($sql_tour);
		if(mysql_num_rows($rs_tour)>0){
			$i=0;
			while($row_tour = mysql_fetch_array($rs_tour)){
				$i++;
				if($i%2==0){
					$row_tour['clear'] = '<br class="clear">';
				}
				
				$row_tour['TourName'] = codau2kodau($row_tour["tour_name"]);
				if($row_tour['tour_image']){
					if(file_exists(const_Web_Path.$path_tour.$row_tour['tour_image'])){
						$row_tour['tour_image']='<img src="'.const_Web_Url.$path_tour.$row_tour['tour_image'].'" width="'.$width.'" height="'.$height.'" title="'.$row_tour['tour_name'].'" alt="'.$row_tour['tour_name'].'" border="0" class="img" />';	
					}else{
						$row_tour['tour_image']='';	
					}
				}else{
					$row_tourv['tour_image']='';
				}
				$xtpl->assign("mod_tour", $mod_tour);	
				
				// ++ travel style
				$sql_travelstyle = "SELECT ts.travelstyle_name FROM ".pre_table."travelstyle ts, ".pre_table."tour_travelstyle t_ts
									WHERE ts.travelstyle_id=t_ts.travelstyle_id AND t_ts.tour_id='".$row_tour['tour_id']."'";
				$rs_travelstyle = execSQL($sql_travelstyle);
				if(mysql_num_rows($rs_travelstyle)>0){
					while($row_travelstyle = mysql_fetch_array($rs_travelstyle)){
						$row_tour['travelstyle_name'] .= $row_travelstyle['travelstyle_name'].', ';
					}
				}
				$row_tour['travelstyle_name'] = substr($row_tour['travelstyle_name'],0, -2);
				// -- travel style
				
				$xtpl->assign("tour",$row_tour);	
				$xtpl->parse("BLOCK.TOUR.TOUR_LIST");
			}				
			$xtpl->parse("BLOCK.TOUR");
		}
	}
	// -- tour
	
	// ++ similar hotel
	if($hotel_similar){
		$sql_similar = "SELECT hotel_id, hotel_name, hotel_image, hotel_brief, c.country_code FROM ".pre_table."hotel h, ".pre_table."country c
						WHERE c.country_id=h.country_id AND hotel_isactive=1 AND hotel_id IN (".$hotel_similar.") ".$cond." 
						ORDER BY hotel_id DESC LIMIT 0, 13";
		$rs_similar = execSQL($sql_similar);
		if(mysql_num_rows($rs_similar)>0){
			$i=0;
			while($row_similar = mysql_fetch_array($rs_similar)){
				$i++;
				if($i%2==0){
					$row_similar['clear'] = '<br class="clear">';
				}
				
				$row_similar['HotelName'] = codau2kodau($row_similar["hotel_name"]);
				if($row_similar['hotel_image']){
					if(file_exists(const_Web_Path.$path.$row_similar['hotel_image'])){
						$row_similar['hotel_image']='<img src="'.const_Web_Url.$path.$row_similar['hotel_image'].'" width="'.$width.'" height="'.$height.'" title="'.$row_similar['hotel_name'].'" alt="'.$row_similar['hotel_name'].'" border="0" class="img" />';	
					}else{
						$row_similar['hotel_image']='';	
					}
				}else{
					$row_similar['hotel_image']='';
				}

				
				$xtpl->assign("similar",$row_similar);	
				$xtpl->parse("BLOCK.SIMILAR.SIMILAR_LIST");
			}				
			$xtpl->parse("BLOCK.SIMILAR");
		}
	}
	// -- similar hotel
	
	// ++ gallery
	$path_gallery = "media/gallery/";
	$width = 230;
	$sql_gallery = "SELECT gallery_id, gallery_name, gallery_image FROM ".pre_table."gallery
					WHERE gallery_isactive=1 AND hotel_id='".$hotel_id."'";
	$rs_gallery = execSQL($sql_gallery);
	while($row_gallery=mysql_fetch_array($rs_gallery)){
		$row_gallery['gallery_url']=const_Web_Url.$path_gallery.$row_gallery['gallery_image'];
		
		if($row_gallery['gallery_image']){
			if(file_exists(const_Web_Path.$path_gallery.$row_gallery['gallery_image'])){
				$row_gallery['gallery_image']='<img src="'.const_Web_Url.$path_gallery.'thumb_'.$width.'_'.$row_gallery['gallery_image'].'" width="'.$width.'" title="'.$row_gallery['gallery_name'].'" alt="'.$row_gallery['gallery_name'].'" border="0" class="img" />';	
			}else{
				$row_gallery['gallery_image']='';	
			}
		}else{
			$row_gallery['gallery_image']='';
		}
		
		$xtpl->assign("gallery",$row_gallery);	
		$xtpl->parse("BLOCK.GALLERY");
	}
	// -- gallery
				
	global $title, $metadescription, $metakeyword;
	$title = $rs['hotel_name'];
	$metadescription = $rs['hotel_metadescription'];
	$metakeyword = $rs['hotel_metakeyword'];
	
	
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;	
}
///
function showBookHotel($sent='', $hotel_id){
	global $lang, $configuration_contact;
	$xtpl=new XTemplate("themes/".theme."/html/bookhotel.htm");	
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('lbl', BookHotel);
		
	$xtpl->assign('CustomerInfo', CustomerInfo);
	$xtpl->assign('Contact', Contact);
	$xtpl->assign('Fullname', Fullname);
	$xtpl->assign('Nationality', Nationality);
	$xtpl->assign('Address', Address);
	$xtpl->assign('Phone', Phone);
	$xtpl->assign('Request', Request);
	$xtpl->assign('SecurityCode', SecurityCode);
		
	$xtpl->assign('Send', Send);
	$xtpl->assign('Back', Back);
		
	$xtpl->assign('Alert', Alert);
	$xtpl->assign('Required', Required);
	$xtpl->assign('LengthPhone', LengthPhone);
	$xtpl->assign('IsNumberic', IsNumberic);
	$xtpl->assign('Invalid', Invalid);
	
	$xtpl->assign('contact_info', $configuration_contact);
	//
	if($hotel_id){
		$cond = " AND lang='".lang."'";
		$sql = "SELECT hotel_name FROM ".pre_table."hotel WHERE hotel_id='".$hotel_id."' ".$cond."";
		$rs = recordset($sql);
		$xtpl->assign('subject', BookHotel.': '.$rs['hotel_name']);
		$xtpl->assign('hotel_id', $hotel_id);
	}
	//
	//

	if($sent==1){
		$xtpl->parse("BLOCK.SENT");
	}
	
	$xtpl->parse("BLOCK");
	$out = $xtpl->text("BLOCK");
	
	return $out;
}
///
function showDaytrip($country_id=''){
	global $lang, $mod_daytrip;
	$xtpl=new XTemplate("themes/".theme."/html/daytrip.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('mod_daytrip', $mod_daytrip);
	
	$xtpl->assign('lbl', Daytrip);
	$xtpl->assign('lbl_more', More);
	
	
	$path = 'media/daytrip/';
	$width = 180;

	
	//
	$cond = " AND d.lang = '".$lang."'";
	if($country_id) $cond .= " AND d.country_id = '".$country_id."'";
	
	// page
	$page=intval($_GET['page']);
	$limit=10;$pagegroup_size=5;
	if (!$page||$page==0){$page=1;}
	$offset=($page-1)*$limit;
	$xtpl->assign("page",$page);
	
	$sql_count = "SELECT d.daytrip_id FROM ".pre_table."daytrip d, ".pre_table."country c
				WHERE c.country_id=d.country_id AND daytrip_isactive=1 ".$cond." ORDER BY daytrip_position";
	$rs_count = execSQL($sql_count);
	$numrec=mysql_num_rows($rs_count);
	
	$sql = "SELECT d.daytrip_id, d.daytrip_name, d.daytrip_brief, d.daytrip_image, c.country_code 
				FROM ".pre_table."daytrip d, ".pre_table."country c 
				WHERE c.country_id=d.country_id AND daytrip_isactive=1 ".$cond." ORDER BY daytrip_position LIMIT $offset, $limit";
	$rs=execSQL($sql);
	if(mysql_num_rows($rs)>0){
		while($row=mysql_fetch_array($rs)){
			$row['DaytripName'] = codau2kodau($row['daytrip_name']);
			
			if($row['daytrip_image']){
				if(file_exists(const_Web_Path.$path.$row['daytrip_image'])){
					$row['daytrip_image'] = '<img src="'.const_Web_Url.$path.'thumb_'.$width.'_'.$row['daytrip_image'].'" width="'.$width.'" title="'.$row['daytrip_name'].'" alt="'.$row['daytrip_name'].'" border="0" vspace="5" hspace="5" class="img" />';	
				}else{
					$row['daytrip_image'] = '';	
				}
			}else{
				$row['daytrip_image'] = '';
			}
			
			$xtpl->assign("list",$row);
			$xtpl->parse("BLOCK.LIST");
		}
		$pages=pagenavigator($page,$numrec,$limit,$pagegroup_size,"page_no",const_Web_Url.'index.php'.$_SERVER['PATH_INFO']."".$page_str."");
		$xtpl->assign("pages",$pages);
		//$xtpl->assign("numrec", "".$numrec."");
	}
	
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;	
}
///
function showDaytripDetail($country_id, $daytrip_id){
	global $lang, $mod_daytrip, $mod_hotel, $mod_bookdaytrip;
	$xtpl=new XTemplate("themes/".theme."/html/daytrip_detail.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('mod_daytrip', $mod_daytrip);
	
	$path = 'media/daytrip/';
	$xtpl->assign('lbl', Tour);
	$xtpl->assign('lbl_overview', Overview);
	$xtpl->assign('lbl_indepth', Indepth);
	$xtpl->assign('lbl_location', Location);
	$xtpl->assign('lbl_traveladvice', TravelAdvice);
	$xtpl->assign('lbl_rates', Rates);
	$xtpl->assign('lbl_hotel', Hotel);
	$xtpl->assign('lbl_similardaytrip', SimilarDaytrip);
	$xtpl->assign('lbl_duration', Duration);
	$xtpl->assign('lbl_travelstyle', TravelStyle);	
	$xtpl->assign('lbl_price', Price);
	$xtpl->assign('lbl_more', More);
	$xtpl->assign('lbl_bookdaytrip', Book);

	$xtpl->assign('mod_bookdaytrip', $mod_bookdaytrip);
	
	//	
	$cond = " AND d.lang='".lang."'";
	$sql = "SELECT d.daytrip_id, d.daytrip_name, d.daytrip_image, d.daytrip_brief, d.daytrip_content, d.daytrip_hotel, d.daytrip_similar, c.city_name
				FROM ".pre_table."daytrip d, ".pre_table."city c
				WHERE d.city_id=c.city_id AND d.daytrip_isactive=1 AND d.daytrip_id='".$daytrip_id."' ".$cond." 
				ORDER BY d.daytrip_position LIMIT 1";
	$rs=recordset($sql);

	$row["daytrip_id"] = $rs["daytrip_id"];
	$row["daytrip_name"] = $rs["daytrip_name"];
	$row['daytrip_brief'] = nl2br($rs['daytrip_brief']);
	$row['daytrip_content'] = $rs['daytrip_content'];
	$row['DaytripName'] = codau2kodau($rs["daytrip_name"]);
	
	if($rs['daytrip_image']){
		if(file_exists(const_Web_Path.$path.$rs['daytrip_image'])){
			$row['daytrip_image']='<img src="'.const_Web_Url.$path.$rs['daytrip_image'].'" width="150" title="'.$rs['daytrip_name'].'" alt="'.$rs['daytrip_name'].'" border="0" vspace="5" hspace="5" class="img" />';	
		}else{
			$row['daytrip_image']='';	
		}
	}else{
		$row['daytrip_image']='';
	}
	
	$row["city_name"] = $rs["city_name"];
	
	$daytrip_hotel = $rs['daytrip_hotel'];
	$daytrip_similar = $rs['daytrip_similar'];
	
	$xtpl->assign("detail",$row);
	
	$width = 230;
	$height = 113;
	// ++ hotel
	if($daytrip_hotel){
		$path_hotel = 'media/hotel/';
		$cond_hotel = " AND h.lang='".lang."'";
		
		$sql_hotel = "SELECT hotel_id, hotel_name, hotel_image, hotel_brief, c.country_code 
						FROM ".pre_table."hotel h, ".pre_table."country c
						WHERE c.country_id=h.country_id AND hotel_isactive=1 AND hotel_id IN (".$daytrip_hotel.") ".$cond_hotel." 
						ORDER BY hotel_id DESC LIMIT 0, 13";
		$rs_hotel = execSQL($sql_hotel);
		if(mysql_num_rows($rs_hotel)>0){
			$i=0;
			while($row_hotel = mysql_fetch_array($rs_hotel)){
				$i++;
				if($i%2==0){
					$row_hotel['clear'] = '<br class="clear">';
				}
				
				$row_hotel['HotelName'] = codau2kodau($row_hotel["hotel_name"]);
				if($row_hotel['hotel_image']){
					if(file_exists(const_Web_Path.$path_hotel.$row_hotel['hotel_image'])){
						$row_hotel['hotel_image']='<img src="'.const_Web_Url.$path_hotel.$row_hotel['hotel_image'].'" width="'.$width.'" height="'.$height.'" title="'.$row_hotel['hotel_name'].'" alt="'.$row_hotel['hotel_name'].'" border="0" class="img" />';	
					}else{
						$row_hotel['hotel_image']='';	
					}
				}else{
					$row_hotelv['hotel_image']='';
				}
				$xtpl->assign("mod_hotel", $mod_hotel);	

				
				$xtpl->assign("hotel",$row_hotel);	
				$xtpl->parse("BLOCK.HOTEL.HOTEL_LIST");
			}				
			$xtpl->parse("BLOCK.HOTEL");
		}
	}
	// -- hotel
	
	// ++ similar daytrip
	if($daytrip_similar){
		$sql_similar = "SELECT daytrip_id, daytrip_name, daytrip_image, daytrip_brief, c.country_code FROM ".pre_table."daytrip d, ".pre_table."country c
						WHERE c.country_id=d.country_id AND daytrip_isactive=1 AND daytrip_id IN (".$daytrip_similar.") ".$cond." 
						ORDER BY daytrip_id DESC LIMIT 0, 10";
		$rs_similar = execSQL($sql_similar);
		if(mysql_num_rows($rs_similar)>0){
			$i=0;
			while($row_similar = mysql_fetch_array($rs_similar)){
				$i++;
				if($i%2==0){
					$row_similar['clear'] = '<br class="clear">';
				}
				
				$row_similar['DaytripName'] = codau2kodau($row_similar["daytrip_name"]);
				if($row_similar['daytrip_image']){
					if(file_exists(const_Web_Path.$path.$row_similar['daytrip_image'])){
						$row_similar['daytrip_image']='<img src="'.const_Web_Url.$path.$row_similar['daytrip_image'].'" width="'.$width.'" height="'.$height.'" title="'.$row_similar['daytrip_name'].'" alt="'.$row_similar['daytrip_name'].'" border="0" class="img" />';	
					}else{
						$row_similar['daytrip_image']='';	
					}
				}else{
					$row_similar['daytrip_image']='';
				}

				
				$xtpl->assign("similar",$row_similar);	
				$xtpl->parse("BLOCK.SIMILAR.SIMILAR_LIST");
			}				
			$xtpl->parse("BLOCK.SIMILAR");
		}
	}
	// -- similar daytrip
				
	global $title, $metadescription, $metakeyword;
	$title = $rs['daytrip_name'];
	$metadescription = $rs['daytrip_metadescription'];
	$metakeyword = $rs['daytrip_metakeyword'];
	
			
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;	
}
///
function showBookDaytrip($sent='', $daytrip_id){
	global $lang, $configuration_contact;
	$xtpl=new XTemplate("themes/".theme."/html/bookdaytrip.htm");	
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('theme_tab', theme_tab);
	$xtpl->assign('lbl', BookDaytrip);
	
	$xtpl->assign('CustomerInfo', CustomerInfo);
	$xtpl->assign('Fullname', Fullname);
	$xtpl->assign('Phone', Phone);
	$xtpl->assign('Fax', Fax);
	$xtpl->assign('ContactDetail', ContactDetail);
	
	$xtpl->assign('DaytripInfo', DaytripInfo);
	$xtpl->assign('DaytripName', DaytripName);
	$xtpl->assign('StartDate', StartDate);
	$xtpl->assign('NumberGuest', NumberGuest);
	$xtpl->assign('NumberRoom', NumberRoom);
	$xtpl->assign('Additonal', Additonal);
	$xtpl->assign('SecurityCode', SecurityCode);
		
	$xtpl->assign('Send', Send);
	$xtpl->assign('Back', Back);
	
	$xtpl->assign('Alert', Alert);
	$xtpl->assign('Required', Required);
	$xtpl->assign('LengthPhone', LengthPhone);
	$xtpl->assign('IsNumberic', IsNumberic);
	$xtpl->assign('Invalid', Invalid);
	
	$xtpl->assign('contact_info', $configuration_contact);
	//
	if($daytrip_id){
		$cond = " AND lang='".lang."'";
		$sql = "SELECT daytrip_name FROM ".pre_table."daytrip WHERE daytrip_id='".$daytrip_id."' ".$cond."";
		$rs = recordset($sql);
		$xtpl->assign('daytrip', $rs['daytrip_name']);
		$xtpl->assign('daytrip_id', $daytrip_id);
	}
	//
	//

	if($sent==1){
		$xtpl->parse("BLOCK.SENT");
	}
	
	$xtpl->parse("BLOCK");
	$out = $xtpl->text("BLOCK");
	
	return $out;
}
///
function showContact($sent=''){
	global $lang, $configuration_contact;
	$xtpl=new XTemplate("themes/".theme."/html/contact.htm");	
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('lbl', Contact);
	
	$xtpl->assign('Contact', Contact);
	$xtpl->assign('Fullname', Fullname);
	$xtpl->assign('Phone', Phone);
	$xtpl->assign('Company', Company);
	$xtpl->assign('Address', Address);
	$xtpl->assign('Subject', Subject);
	$xtpl->assign('Message', Message);
	$xtpl->assign('SecurityCode', SecurityCode);
	$xtpl->assign('Send', Send);
	$xtpl->assign('Back', Back);
	
	$xtpl->assign('Alert', Alert);
	$xtpl->assign('Required', Required);
	$xtpl->assign('LengthPhone', LengthPhone);
	$xtpl->assign('Invalid', Invalid);
	
	$xtpl->assign('contact_info', $configuration_contact);
	
	//

	if($sent==1){
		$xtpl->parse("BLOCK.SENT");
	}
	
	$xtpl->parse("BLOCK");
	$out = $xtpl->text("BLOCK");
	
	return $out;
}
///
function showSearchResultTour($keyword='', $country_id='', $travelstyle_id=''){
	global $lang, $mod, $mod_tour;
	$xtpl=new XTemplate("themes/".theme."/html/tour_searchresult.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('mod_tour', $mod_tour);
	
	$xtpl->assign('lbl', Tour.' '.SearchResult);
	$xtpl->assign('lbl_more', More);
	
	
	$path = 'media/tour/';
	$width = 180;

	
	
	//
	$cond = " AND t.lang = '".$lang."'";
	
	if($keyword) $cond .= " AND (t.tour_name like '%".trim($keyword)."%' OR t.tour_brief like '%".trim($keyword)."%' OR t.tour_overview like '%".trim($keyword)."%' OR t.tour_itinerary like '%".trim($keyword)."%' OR t.tour_rates like '%".trim($keyword)."%')";
	
	if($country_id) $cond .= " AND t.country_id = '".$country_id."'";
	
	if($travelstyle_id){
		$sql_ts = "SELECT tour_id FROM ".pre_table."tour_travelstyle WHERE travelstyle_id='".$travelstyle_id."'";
		$rs_ts = execSQL($sql_ts);
		if(mysql_num_rows($rs_ts)>0){
			while($row_ts=mysql_fetch_array($rs_ts)){
				$arr_ts[] = $row_ts['tour_id'];
			}
			$in_ts = implode(",", $arr_ts);
			$cond .= " AND t.tour_id IN (".$in_ts.")";
		}else{
			$cond .= " AND t.tour_id=''";
		}
	}
	// page
	$page=intval($_GET['page']);
	$limit=10;$pagegroup_size=5;
	if (!$page||$page==0){$page=1;}
	$offset=($page-1)*$limit;
	$xtpl->assign("page",$page);
	
	$sql_count = "SELECT t.tour_id FROM ".pre_table."tour t, ".pre_table."country c
				WHERE c.country_id=t.country_id AND tour_isactive=1 ".$cond." ORDER BY tour_position";
	$rs_count = execSQL($sql_count);
	$numrec=mysql_num_rows($rs_count);
	
	$sql = "SELECT t.tour_id, t.tour_name, t.tour_brief, t.tour_image, c.country_code FROM ".pre_table."tour t, ".pre_table."country c 
				WHERE c.country_id=t.country_id AND tour_isactive=1 ".$cond." ORDER BY tour_position LIMIT $offset, $limit";
	$rs=execSQL($sql);
	if(mysql_num_rows($rs)>0){
		while($row=mysql_fetch_array($rs)){
			$row['TourName'] = codau2kodau($row['tour_name']);
			
			if($row['tour_image']){
				if(file_exists(const_Web_Path.$path.$row['tour_image'])){
					$row['tour_image'] = '<img src="'.const_Web_Url.$path.'thumb_'.$width.'_'.$row['tour_image'].'" width="'.$width.'" title="'.$row['tour_name'].'" alt="'.$row['tour_name'].'" border="0" vspace="5" hspace="5" class="img" />';	
				}else{
					$row['tour_image'] = '';	
				}
			}else{
				$row['tour_image'] = '';
			}
			
			$xtpl->assign("list",$row);
			$xtpl->parse("BLOCK.LIST");
		}
		$pages=pagenavigator($page,$numrec,$limit,$pagegroup_size,"page_no",const_Web_Url.'index.php/'.$mod.'?'.$_SERVER['QUERY_STRING']);
		$xtpl->assign("pages",$pages);
		$xtpl->assign("numrec", ": ".$numrec." ".Tour);
	}else{
	
		$xtpl->assign('lbl_notfound', NotFound);
		$xtpl->parse("BLOCK.NOT_FOUND");
	}
	
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;
}
///
function showSearchResultHotel($keyword='', $country_id='', $city_id=''){
	global $lang, $mod, $mod_hotel;
	$xtpl=new XTemplate("themes/".theme."/html/hotel_searchresult.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('mod_hotel', $mod_hotel);
	
	$xtpl->assign('lbl', Hotel.' '.SearchResult);
	$xtpl->assign('lbl_more', More);

	$path = 'media/hotel/';
	$width = 180;

	
	//
	$cond = " AND h.lang = '".$lang."'";
	
	if($keyword) $cond .= " AND (h.hotel_name like '%".trim($keyword)."%' OR h.hotel_brief like '%".trim($keyword)."%' OR h.hotel_overview like '%".trim($keyword)."%' OR h.hotel_indepth like '%".trim($keyword)."%' OR h.hotel_location like '%".trim($keyword)."%' OR h.hotel_traveladvice like '%".trim($keyword)."%' OR h.hotel_rates like '%".trim($keyword)."%')";
	
	if($country_id) $cond .= " AND h.country_id = '".$country_id."'";
	if($city_id) $cond .= " AND h.city_id = '".$city_id."'";

	
	// page
	$page=intval($_GET['page']);
	$limit=10;$pagegroup_size=5;
	if (!$page||$page==0){$page=1;}
	$offset=($page-1)*$limit;
	$xtpl->assign("page",$page);
	
	$sql_count = "SELECT h.hotel_id FROM ".pre_table."hotel h, ".pre_table."country c
				WHERE c.country_id=h.country_id AND hotel_isactive=1 ".$cond." ORDER BY hotel_position";
	$rs_count = execSQL($sql_count);
	$numrec=mysql_num_rows($rs_count);
	
	$sql = "SELECT h.hotel_id, h.hotel_name, h.hotel_brief, h.hotel_image, c.country_code 
				FROM ".pre_table."hotel h, ".pre_table."country c 
				WHERE c.country_id=h.country_id AND hotel_isactive=1 ".$cond." ORDER BY hotel_position LIMIT $offset, $limit";
	$rs=execSQL($sql);
	if(mysql_num_rows($rs)>0){
		while($row=mysql_fetch_array($rs)){
			$row['HotelName'] = codau2kodau($row['hotel_name']);
			
			if($row['hotel_image']){
				if(file_exists(const_Web_Path.$path.$row['hotel_image'])){
					$row['hotel_image'] = '<img src="'.const_Web_Url.$path.'thumb_'.$width.'_'.$row['hotel_image'].'" width="'.$width.'" title="'.$row['hotel_name'].'" alt="'.$row['hotel_name'].'" border="0" vspace="5" hspace="5" class="img" />';	
				}else{
					$row['hotel_image'] = '';	
				}
			}else{
				$row['hotel_image'] = '';
			}
			
			$xtpl->assign("list",$row);
			$xtpl->parse("BLOCK.LIST");
		}
		$pages=pagenavigator($page,$numrec,$limit,$pagegroup_size,"page_no",const_Web_Url.'index.php/'.$mod.'?'.$_SERVER['QUERY_STRING']);
		$xtpl->assign("pages",$pages);
		$xtpl->assign("numrec", ": ".$numrec." ".Hotel);
	}else{
	
		$xtpl->assign('lbl_notfound', NotFound);
		$xtpl->parse("BLOCK.NOT_FOUND");
	}
	
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;	
}
///
function showSearchResultDaytrip($keyword='', $country_id='', $city_id='', $travelstyle_id=''){
	global $lang, $mod, $mod_daytrip;
	$xtpl=new XTemplate("themes/".theme."/html/daytrip_searchresult.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('mod_daytrip', $mod_daytrip);
	
	$xtpl->assign('lbl', Daytrip.' '.SearchResult);
	$xtpl->assign('lbl_more', More);
	
	
	$path = 'media/daytrip/';
	$width = 180;
	
	//
	$cond = " AND d.lang = '".$lang."'";
	
	if($keyword) $cond .= " AND (d.daytrip_name like '%".trim($keyword)."%' OR d.daytrip_brief like '%".trim($keyword)."%' OR d.daytrip_content like '%".trim($keyword)."%')";
	
	if($country_id) $cond .= " AND d.country_id = '".$country_id."'";
	if($city_id) $cond .= " AND d.city_id = '".$city_id."'";
	
	if($travelstyle_id){
		$sql_ts = "SELECT daytrip_id FROM ".pre_table."daytrip_travelstyle WHERE travelstyle_id='".$travelstyle_id."'";
		$rs_ts = execSQL($sql_ts);
		if(mysql_num_rows($rs_ts)>0){
			while($row_ts=mysql_fetch_array($rs_ts)){
				$arr_ts[] = $row_ts['daytrip_id'];
			}
			$in_ts = implode(",", $arr_ts);
			$cond .= " AND d.daytrip_id IN (".$in_ts.")";
		}else{
			$cond .= " AND d.daytrip_id=''";
		}
	}
	
	//
	$page=intval($_GET['page']);
	$limit=10;$pagegroup_size=5;
	if (!$page||$page==0){$page=1;}
	$offset=($page-1)*$limit;
	$xtpl->assign("page",$page);
	
	$sql_count = "SELECT d.daytrip_id FROM ".pre_table."daytrip d, ".pre_table."country c
				WHERE c.country_id=d.country_id AND daytrip_isactive=1 ".$cond." ORDER BY daytrip_position";
	$rs_count = execSQL($sql_count);
	$numrec=mysql_num_rows($rs_count);
	
	$sql = "SELECT d.daytrip_id, d.daytrip_name, d.daytrip_brief, d.daytrip_image, c.country_code 
				FROM ".pre_table."daytrip d, ".pre_table."country c 
				WHERE c.country_id=d.country_id AND daytrip_isactive=1 ".$cond." ORDER BY daytrip_position LIMIT $offset, $limit";
	$rs=execSQL($sql);
	if(mysql_num_rows($rs)>0){
		while($row=mysql_fetch_array($rs)){
			$row['DaytripName'] = codau2kodau($row['daytrip_name']);
			
			if($row['daytrip_image']){
				if(file_exists(const_Web_Path.$path.$row['daytrip_image'])){
					$row['daytrip_image'] = '<img src="'.const_Web_Url.$path.'thumb_'.$width.'_'.$row['daytrip_image'].'" width="'.$width.'" title="'.$row['daytrip_name'].'" alt="'.$row['daytrip_name'].'" border="0" vspace="5" hspace="5" class="img" />';	
				}else{
					$row['daytrip_image'] = '';	
				}
			}else{
				$row['daytrip_image'] = '';
			}
			
			$xtpl->assign("list",$row);
			$xtpl->parse("BLOCK.LIST");
		}
		$pages=pagenavigator($page,$numrec,$limit,$pagegroup_size,"page_no",const_Web_Url.'index.php/'.$mod.'?'.$_SERVER['QUERY_STRING']);
		$xtpl->assign("pages",$pages);
		$xtpl->assign("numrec", ": ".$numrec." ".Daytrip);
	}else{
	
		$xtpl->assign('lbl_notfound', NotFound);
		$xtpl->parse("BLOCK.NOT_FOUND");
	}
	
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;		
}
///
function showDestination(){
	global $lang, $mod_destination, $country_array;
	$xtpl=new XTemplate("themes/".theme."/html/destination.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('mod_destination', $mod_destination);
	
	$xtpl->assign('lbl_more', More);
	
	
	$path = 'media/destination/';
	$width = 230;
	$height = 113;

	
	//
	$cond = " AND d.lang = '".$lang."'";
	if($catdestination_id) $cond .= " AND h.catdestination_id = '".$catdestination_id."'";
	
	$sql_cat = "SELECT catdestination_id, catdestination_name FROM ".pre_table."catdestination 
				WHERE catdestination_isactive=1 AND lang='".$lang."'";
	$rs_cat = execSQL($sql_cat);
	if(mysql_num_rows($rs_cat)>0){
		
		while($row_cat=mysql_fetch_array($rs_cat)){
			$sql = "SELECT d.destination_id, d.destination_name, d.destination_brief, d.destination_image FROM ".pre_table."destination d
				WHERE d.catdestination_id='".$row_cat['catdestination_id']."' AND destination_isactive=1 ".$cond." 
				ORDER BY destination_position";
			$rs=execSQL($sql);
			if(mysql_num_rows($rs)>0){
				$i=0;
				while($row=mysql_fetch_array($rs)){
					$i++;
					if($i%2==0){
						$row['clear'] = '<br class="clear">';
					}
					
					$row['DestinationName'] = codau2kodau($row['destination_name']);
					$row['destination_brief'] = cutString($row['destination_brief'], 130);
					
					if($row['destination_image']){
						if(file_exists(const_Web_Path.$path.$row['destination_image'])){
							$row['destination_image'] = '<img src="'.const_Web_Url.$path.$row['destination_image'].'" width="'.$width.'" height="'.$height.'" title="'.$row['destination_name'].'" alt="'.$row['destination_name'].'" border="0" vspace="5" hspace="5" class="img" />';	
						}else{
							$row['destination_image'] = '';	
						}
					}else{
						$row['destination_image'] = '';
					}
		
					$xtpl->assign("list",$row);
					$xtpl->parse("BLOCK.CAT.LIST");
				}
			}
			
			//
			$xtpl->assign("cat",$row_cat);
			$xtpl->parse("BLOCK.CAT");

		}
	}
	
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;	
}
function showDestinationDetail($destination_id){
	global $lang, $mod_destination;
	$xtpl=new XTemplate("themes/".theme."/html/destination_detail.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	$xtpl->assign('theme_tab', theme_tab);
	$xtpl->assign('mod_destination', $mod_destination);
	
	$path = 'media/destination/';
	$width = 230;
	$height = 113;
	
	$xtpl->assign('lbl', Destination);
	$xtpl->assign('lbl_overview', Overview);
	$xtpl->assign('lbl_gallery', Gallery);
	$xtpl->assign('lbl_more', More);
	
	$xtpl->assign('mod_bookdestination', $mod_bookdestination);
	
	//	
	$cond = " AND d.lang='".lang."'";
	$sql = "SELECT d.destination_id, d.destination_name, d.destination_image, d.destination_brief, d.destination_content, destination_metadescription, destination_metakeyword, c.catdestination_id, c.catdestination_name
				FROM ".pre_table."destination d, ".pre_table."catdestination c
				WHERE d.catdestination_id=c.catdestination_id AND 
						d.destination_isactive=1 AND d.destination_id='".$destination_id."' ".$cond." 
				ORDER BY d.destination_position LIMIT 1";
	$rs=recordset($sql);


	$row["destination_id"] = $rs["destination_id"];
	$row["catdestination_name"] = $rs["catdestination_name"];
	$row["destination_name"] = $rs["destination_name"];
	$row['destination_brief'] = nl2br($rs['destination_brief']);
	$row['destination_content'] = $rs['destination_content'];
	$row['DestinationName'] = codau2kodau($rs["destination_name"]);
	
	if($rs['destination_image']){
		if(file_exists(const_Web_Path.$path.$rs['destination_image'])){
			$row['destination_image']='<img src="'.const_Web_Url.$path.$rs['destination_image'].'" width="150" title="'.$rs['destination_name'].'" alt="'.$rs['destination_name'].'" border="0" vspace="5" hspace="5" class="img" />';	
		}else{
			$row['destination_image']='';	
		}
	}else{
		$row['destination_image']='';
	}
	$xtpl->assign("detail",$row);
	
	// ++ other destination
	if($rs["destination_id"]){
		$sql_other = "SELECT destination_id, destination_name, destination_image, destination_brief
				FROM ".pre_table."destination d
					WHERE destination_isactive=1 AND destination_id <> '".$destination_id."' 
					AND catdestination_id='".$rs["catdestination_id"]."' ".$cond." 
					ORDER BY destination_id DESC LIMIT 0, 13";
		$rs_other = execSQL($sql_other);
		if(mysql_num_rows($rs_other)>0){
			$i=0;
			while($row_other = mysql_fetch_array($rs_other)){
				$i++;
				if($i%2==0){
					$row_other['clear'] = '<br class="clear">';
				}
				
				$row_other['DestinationName'] = codau2kodau($row_other['destination_name']);
				$row_other['destination_brief'] = cutString($row_other['destination_brief'], 130);

				if($row_other['destination_image']){
					if(file_exists(const_Web_Path.$path.$row_other['destination_image'])){
						$row_other['destination_image'] = '<img src="'.const_Web_Url.$path.$row_other['destination_image'].'" width="'.$width.'" height="'.$height.'" title="'.$row_other['destination_name'].'" alt="'.$row_other['destination_name'].'" border="0" vspace="5" hspace="5" class="img" />';	
					}else{
						$row_other['destination_image'] = '';	
					}
				}else{
					$row_other['destination_image'] = '';
				}

				
				$xtpl->assign("list",$row_other);	
				$xtpl->parse("BLOCK.LIST");
			}				
		}
	}
	// -- other destination
	
	// ++ gallery
	$path_gallery = "media/gallery/";
	$width = 230;
	$sql_gallery = "SELECT gallery_id, gallery_name, gallery_image FROM ".pre_table."gallery
					WHERE gallery_isactive=1 AND destination_id='".$destination_id."'";
	$rs_gallery = execSQL($sql_gallery);
	while($row_gallery=mysql_fetch_array($rs_gallery)){
		$row_gallery['gallery_url']=const_Web_Url.$path_gallery.$row_gallery['gallery_image'];
		
		if($row_gallery['gallery_image']){
			if(file_exists(const_Web_Path.$path_gallery.$row_gallery['gallery_image'])){
				$row_gallery['gallery_image']='<img src="'.const_Web_Url.$path_gallery.'thumb_'.$width.'_'.$row_gallery['gallery_image'].'" width="'.$width.'" title="'.$row_gallery['gallery_name'].'" alt="'.$row_gallery['gallery_name'].'" border="0" />';	
			}else{
				$row_gallery['gallery_image']='';	
			}
		}else{
			$row_gallery['gallery_image']='';
		}
		
		$xtpl->assign("gallery",$row_gallery);	
		$xtpl->parse("BLOCK.GALLERY");
	}
	// -- gallery
	
	global $title, $metadescription, $metakeyword;
	$title = $rs['destination_name'];
	$metadescription = $rs['destination_metadescription'];
	$metakeyword = $rs['destination_metakeyword'];
	
		
						
    $xtpl->parse("BLOCK");
	$out_html = $xtpl->text("BLOCK");

	return $out_html;	
}

///
function showUtilityCurrency(){
	global $lang;
	$xtpl=new XTemplate("themes/".theme."/html/utility_currency.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);
	
	$xtpl->assign('lbl', ExchangeRate);
	$xtpl->assign('lbl_source', Source);
	
		
	$sql="SELECT * FROM tygia
			WHERE Status=1 ORDER BY Date DESC";
	$rs=execSQL($sql);
	while($row=mysql_fetch_array($rs)){
		$Date = Printdate($row['Date'], false, $lang);
		
		$xtpl->assign("list",$row);
		$xtpl->parse("BLOCK.LIST");
	}		
	$xtpl->assign("Date",$Date);
	
	$xtpl->parse("BLOCK");
	$out = $xtpl->text("BLOCK");
	
	return $out;
}
///
function showUtilityWeather(){
	global $lang;
	$xtpl=new XTemplate("themes/".theme."/html/utility_weather.htm");
	$xtpl->assign('const_Web_Url', const_Web_Url);
	$xtpl->assign('theme', theme);

	$xtpl->assign('lbl', Weather);
	$xtpl->assign('lbl_source', Source);
			
	$sql="SELECT * FROM thoitiet
			WHERE Status=1 ORDER BY Date DESC";
	$rs=execSQL($sql);
	while($row=mysql_fetch_array($rs)){
		$row['Temperature'] = $row['Temperature'].'<sup>o</sup>C'; 
		$row['Desc'] = '<img src="'.$row['Desc'].'" border="0" width="30" valign="top" />'; 
		$Date = Printdate($row['Date'], false, $lang); 
	
		$xtpl->assign("list",$row);
		$xtpl->parse("BLOCK.LIST");
	}		
	$xtpl->assign("Date",$Date);
	
	$xtpl->parse("BLOCK");
	$out = $xtpl->text("BLOCK");
	
	return $out;
}
?>